package weekMatch.one_351;

public class LeeCode_01 {
    public static void main(String[] args) {

    }
    private static int countBeautifulPairs(int[] nums) {
        int ans = 0, n = nums.length;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int n1 = Integer.toString(nums[i]).charAt(0) - '0';
                String s2 = Integer.toString(nums[j]);
                int n2 = s2.charAt(s2.length() - 1) - '0';
                if (gcd(n1, n2) == 1)
                    ans++;
            }
        }
        return ans;
    }
    private static int gcd(int x, int y){
        while (x != 0){
            int tmp = x;
            x = y % x;
            y = tmp;
        }
        return y;
    }
}